package com.wondersgroup.framework.sample.component.demoform.vs.impl;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.List;
import org.apache.log4j.Logger;
import com.wondersgroup.framework.sample.component.demoform.vo.UploadVO;
import com.wondersgroup.framework.sample.component.demoform.vs.DemoVS;
import com.wondersgroup.wssip.bc.facade.annotations.FacadeAutowired;
import com.wondersgroup.wssip.commons.file.ImportResult;
import com.wondersgroup.wssip.commons.file.excel.ExcelService;
import com.wondersgroup.wssip.commons.file.excel.impl.ExcelServiceImpl;

@FacadeAutowired
public class DemoVSImpl implements DemoVS {
	public Logger logger = Logger.getLogger(this.getClass());

	public void doImport(UploadVO uploadVO) {
		ExcelService excelService = new ExcelServiceImpl();
		ImportResult importResult = null;
		List<List<String>> resultList = null;
		for (File file : uploadVO.getFileData()) {
			try {
				importResult = excelService.read(new FileInputStream(file), 1);
				resultList = importResult.getResultList();
				for (List<String> outList : resultList) {
					for (String s : outList) {
						System.out.print(s + "	");
					}
					System.out.println();
				}
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}
	}
}
